package net.magicalcloud.magicalcloud.presenter;

import net.magicalcloud.magicalcloud.AppApplication;
import net.magicalcloud.magicalcloud.base.BasePresenter;
import net.magicalcloud.magicalcloud.entity.Files;
import net.magicalcloud.magicalcloud.execption.CloudExecption;
import net.magicalcloud.magicalcloud.listener.CloudListener;
import net.magicalcloud.magicalcloud.model.IFileModel;
import net.magicalcloud.magicalcloud.model.modelImpl.FileModel;
import net.magicalcloud.magicalcloud.view.IVagueSearchView;

import java.util.List;

/**
 * Created by Administrator on 2018/6/8.
 */

public class VagueSearchPresenter extends BasePresenter<IVagueSearchView> {

    private IFileModel fileModel=new FileModel();


    /**
     * 模糊搜索文件
     */

    public void vagueSearch(String value){
        int userId=AppApplication.getCurrentUser().getId();

        CloudListener<List<Files>> vlistener=new CloudListener<List<Files>>() {
            @Override
            public void done(List<Files> object, CloudExecption e) {
                if(e==null){
                    getView().setList(object);
                }
                else {
                    getView().setList(null);
                }
            }
        };

        fileModel.vagueSearchFile(value, userId,vlistener);


    }
}
